@extends('home.frame')
@section('content')
	<link href="/ho/css/addstyle.css" rel="stylesheet" type="text/css">
	<script src="/layer/layer.js"></script>
	<meta name="csrf-token" content="{{ csrf_token() }}" />
	<script src="/ho/area.js"></script>
			<div class="user-address">
				<!--标题 -->
				<div class="am-cf am-padding">
					<div class="am-fl am-cf"><strong class="am-text-danger am-text-lg">地址管理</strong> / <small>Address&nbsp;list</small></div>
				</div>
				<hr/>
				<ul class="am-avg-sm-1 am-avg-md-3 am-thumbnails">
					@foreach($address as $k=>$v)
					<li class="user-addresslist ">
						<span class="new-option-r"><i class="am-icon-check-circle"></i>默认地址</span>
						<p class="new-tit new-p-re">
							<span class="new-txt">
								{{$v['bconsignee']}}
							</span>
							<span class="new-txt-rd2">{{$v['bphone']}}</span>
						</p>
						<div class="new-mu_l2a new-p-re">
							<p class="new-mu_l2cw">
								<span class="title">地址：</span>

								<span class="street">{{$v['baddress']}}</span></p>
						</div>
						<div class="new-addr-btn">
							<a href="/home/address/edit/{{$v['bid']}}"><i class="am-icon-edit"></i>编辑</a>
							<span class="new-addr-bar">|</span>
							<a href="javascript:void(0);" onClick="delClick({{$v['bid']}});"  ><i class="am-icon-trash"></i>删除</a>
						</div>
					</li>

@endforeach

				</ul>
				<script type="text/javascript">
					function delClick(bid){
                        layer.confirm('是否确定删除', {
                            btn: ['是','否'] //按钮
                        }, function(){
                            $.ajaxSetup({
                                headers: {
                                    'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                                }
                            });

                            $.post('/home/address/del',{'bid':bid },
								function(msg){
                               		if(msg){
                                        layer.msg('删除成功', {icon: 1});
                                        window.location.href = "/home/address";
									}
								}
							);

                        }, function(){

                        });
					}
				</script>
				<div class="clear"></div>
				<a class="new-abtn-type" data-am-modal="{target: '#doc-modal-1', closeViaDimmer: 0}">添加新地址</a>
				<!--例子-->
				<div class="am-modal am-modal-no-btn" id="doc-modal-1">

					<div class="add-dress">

						<!--标题 -->
						<div class="am-cf am-padding">
							<div class="am-fl am-cf"><strong class="am-text-danger am-text-lg">新增地址</strong> / <small>Add&nbsp;address</small></div>
						</div>
						<hr/>

						<div class="am-u-md-12 am-u-lg-8" style="margin-top: 20px;">
							<form class="am-form am-form-horizontal" method="post" action="/home/address/sort">
								{{ csrf_field() }}
								<input type="hidden"  placeholder="用户" name="buid" value="{{$uid}}">
								<div class="am-form-group">
									<label for="user-name" class="am-form-label">收货人</label>
									<div class="am-form-content">
										<input type="text" id="user-name" placeholder="收货人" name="bconsignee">
									</div>
								</div>

								<div class="am-form-group">
									<label for="user-phone" class="am-form-label">手机号码</label>
									<div class="am-form-content">
										<input id="user-phone" placeholder="手机号必填" type="text" name="bphone">
									</div>
								</div>
								<div class="am-form-group">
									<label for="user-phone" class="am-form-label">邮编</label>
									<div class="am-form-content">
										<input id="user-phone" placeholder="邮编必填" type="text" name="bpostalcode">
									</div>
								</div>
								<div class="am-form-group">
									<label for="user-address" class="am-form-label">所在地</label>
									<div class="am-form-content address">
										{{--<select data-am-selected>--}}
											{{--<option value="a">浙江省</option>--}}
											{{--<option value="b" selected>湖北省</option>--}}
										{{--</select>--}}
										{{--<select data-am-selected>--}}
											{{--<option value="a">温州市</option>--}}
											{{--<option value="b" selected>武汉市</option>--}}
										{{--</select>--}}
										{{--<select data-am-selected>--}}
											{{--<option value="a">瑞安区</option>--}}
											{{--<option value="b" selected>洪山区</option>--}}
										{{--</select>--}}
										<select data-am-selected id="Province" runat="server" name="province" style="width: 90px" ></select>
										<select data-am-selected id="Country" runat="server" name="country" style="width: 90px"></select>
										<select data-am-selected id="Town" runat="server" name="town" style="width: 90px"></select>

										<script language="javascript">
                                            setup();
										</script>
									</div>
								</div>

								<div class="am-form-group">
									<label for="user-intro" class="am-form-label">详细地址</label>
									<div class="am-form-content">
										<textarea class="" rows="3" id="user-intro" placeholder="输入详细地址" name="baddress"></textarea>
										<small>100字以内写出你的详细地址...</small>
									</div>
								</div>

								<div class="am-form-group">
									<div class="am-u-sm-9 am-u-sm-push-3">
										{{--<a class="am-btn am-btn-danger">保存</a>--}}
										<button type="submit">保存</button>
										<a href="/ho/javascript: void(0)" class="am-close am-btn am-btn-danger" data-am-modal-close>取消</a>
									</div>
								</div>
							</form>
						</div>

					</div>

				</div>

			</div>
	<script type="text/javascript">
        $(document).ready(function() {
            $(".new-option-r").click(function() {
                $(this).parent('.user-addresslist').addClass("defaultAddr").siblings().removeClass("defaultAddr");
            });

            var $ww = $(window).width();
            if($ww>640) {
                $("#doc-modal-1").removeClass("am-modal am-modal-no-btn")
            }

        })
	</script>
@endsection
